package com.anycl.design.structural.composite;

/**
 * 组合模式
 */
public class Man {

    public static void main(String[] args) {
        Composite root = new Composite("综合实验室");
        root.add(new Leaf("综合设备1"));
        root.add(new Leaf("综合设备2"));

        Composite branchLevel21 = new Composite("化学实验室");
        branchLevel21.add(new Leaf("试管"));
        branchLevel21.add(new Leaf("烧杯"));
        branchLevel21.add(new Leaf("锥形瓶"));
        root.add(branchLevel21);

        Composite branchLevel22 = new Composite("物理实验室");
        branchLevel22.add(new Leaf("电磁箱"));
        branchLevel22.add(new Leaf("电源"));
        root.add(branchLevel22);

        root.display(1);
    }
}
